/*
*  SkyUtils.cpp
*  
*
*  Created by Alexander Trutchenko on 11/02/12.
*  Copyright 2012 Free Team. All rights reserved.
*
*/

#include "SkyUtils.h"

namespace sky {

#define SKY_EXT_TO_MIME_SIZE 26
static const char* s_extToMime[SKY_EXT_TO_MIME_SIZE] = 
{
"au",	"audio/basic",
"snd",	"audio/basic",
"mid",	"audio/mid",
"rmi",	"audio/mid",
"mp3",	"audio/mpeg",
"aif",	"audio/x-aiff",
"aifc",	"audio/x-aiff",
"aiff",	"audio/x-aiff",
"m3u",	"audio/x-mpegurl",
"ra",	"audio/x-pn-realaudio",
"ram",	"audio/x-pn-realaudio",
"wav",	"audio/wav",
"wav",	"audio/x-wav",
};

void getFileExtFromMimeType(const std::string& mimeType, std::vector<std::string>& extentions)
{
	for (unsigned int i = 0; i < SKY_EXT_TO_MIME_SIZE; i += 2)
		if (mimeType == s_extToMime[i+1])
			extentions.push_back(s_extToMime[i]);
}

void getMimeTypesFromFileExt(const std::string& fileExt, std::vector<std::string>& mimeTypes)
{
	for (unsigned int i = 0; i < SKY_EXT_TO_MIME_SIZE; i += 2)
		if (fileExt == s_extToMime[i])
			mimeTypes.push_back(s_extToMime[i+1]);
}

// Common


} // namespace sky
